<!DOCTYPE html>
<html>

<head>
    <include file="public@head" title="网站设置"/>
</head>

<body class="layui-layout-admin">
<include file="public@header"/>
<include file="public@side"/>

<div class="layui-body">
    <div class="layui-breadcrumb" lay-filter="breadcrumb">
        <a href="{:url('admin/index/index')}">主页</a>
        <a>系统设置</a>
        <a href="{:url('admin/mailer/index')}"><cite>网站信息</cite></a>
    </div>
    <div class="layui-fluid">
        <div class="layui-card">
            <!--            <div class="layui-card-header">-->
            <!--                站点信息-->
            <!--            </div>-->
            <div class="layui-card-body layui-row layui-col-space15">
                <form class="layui-form" action="{:url('admin/setting/site')}" method="post">
                    <div class="layui-col-md4">
                        <div class="layui-card">
                            <div class="layui-card-header">
                                站点信息
                            </div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <label class="layui-form-label"><span class="form-required">*</span>网站名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" lay-verify="required"
                                               name="options[site_name]" value="{$site_name|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">备案信息</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[site_icp]"
                                               value="{$site_icp|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">公司名称</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[company_name]"
                                               value="{$company_name|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">联系地址</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[address]"
                                               value="{$address|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">联系电话</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[phone]"
                                               value="{$phone|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">工作时间</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[worktime]"
                                               value="{$worktime|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">在线QQ</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[qq]"
                                               value="{$qq|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">电子邮箱</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" lay-verify="email"
                                               name="options[site_email]"
                                               value="{$site_email|default=''}">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <div class="layui-card">
                            <div class="layui-card-header">SEO设置</div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">SEO标题</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[site_seo_title]"
                                               value="{$site_seo_title|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">SEO关键词</label>
                                    <div class="layui-input-block">
                                        <input type="text" class="layui-input" name="options[site_seo_keywords]"
                                               value="{$site_seo_keywords|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">SEO摘要</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea" name="options[site_seo_description]">{$site_seo_description|default=''}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">统计代码</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea" name="options[site_analytics]">{$site_analytics|default=''}</textarea>
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">版权信息</label>
                                    <div class="layui-input-block">
                                        <textarea class="layui-textarea" name="options[site_copyright]">{$site_copyright|default=''}</textarea>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <div class="layui-card">
                            <div class="layui-card-header">
                                图片设置
                            </div>
                            <div class="layui-card-body">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">Logo</label>
                                    <div class="layui-input-block">
                                        <a id="btn-logo">
                                            <empty name="logo">
                                                <img src="__STATIC__/images/default-thumb.png" id="logo-preview"
                                                     width="135"
                                                     height="135" style="cursor: pointer"/>
                                                <else/>
                                                <img src="{:get_image_url($logo)}" id="logo-preview" width="135"
                                                     height="135" style="cursor: pointer"/>
                                            </empty>
                                        </a>
                                        <input type="hidden" name="options[logo]" id="input-logo"
                                               value="{$logo|default=''}">
                                    </div>
                                </div>
                                <div class="layui-form-item">
                                    <label class="layui-form-label">公众号</label>
                                    <div class="layui-input-block">
                                        <a id="btn-wechat">
                                            <empty name="wechat">
                                                <img src="__STATIC__/images/default-thumb.png" id="wechat-preview"
                                                     width="135" height="135" style="cursor: pointer"/>
                                                <else/>
                                                <img src="{:get_image_url($wechat)}" id="wechat-preview" width="135"
                                                     height="135" style="cursor: pointer"/>
                                            </empty>
                                        </a>
                                        <input type="hidden" name="options[wechat]" id="input-wechat"
                                               value="{$wechat|default=''}">
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-form-item">
                        <div class="layui-input-block">
                            <button type="submit" class="layui-btn layui-btn-primary" lay-submit lay-filter="save">
                                保存修改
                            </button>
                        </div>
                    </div>
                </form>
            </div>
        </div>

    </div>
</div>
<include file="public@scripts"/>
<script>
    var upload = layui.upload;

    upload.render({
        elem: '#btn-logo',
        url: "{:url('api/asset/fileUpload')}",
        exts: 'jpg|png|bmp|jpeg',
        data: {path: 'site'},
        before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#logo-preview').attr('src', result); //图片链接（base64）
            });
        },
        done: function (res) {
            if (res.code == 0) {
                return layer.msg(res.message);
            }
            $('#input-logo').val(res.filepath);
        }
    });

    upload.render({
        elem: '#btn-wechat',
        url: "{:url('api/asset/fileUpload')}",
        exts: 'jpg|png|bmp|jpeg',
        data: {path: 'site'},
        before: function (obj) {
            obj.preview(function (index, file, result) {
                $('#wechat-preview').attr('src', result); //图片链接（base64）
            });
        },
        done: function (res) {
            if (res.code == 0) {
                return layer.msg(res.message);
            }
            $('#input-wechat').val(res.filepath);
        }
    });

    form.on('submit(save)', function (data) {
        $.post(data.action, data.field, function (res) {
            layer.msg(res.msg, {}, function () {
                if (res.url) { //如果返回值有需要跳转的url则跳转，否则重载当前页面
                    window.location.href = res.url;
                } else {
                    window.location.reload();
                }
            });
        });
        return false;
    });
</script>
</body>

</html>
